package com.zhala.system.service.impl;

import com.zhala.system.domain.ZlHumanNumberStatistic;
import com.zhala.system.domain.vo.StatisticFindVO;
import com.zhala.system.domain.vo.StatisticVO;
import com.zhala.system.mapper.ZlHumanNumberStatisticMapper;
import com.zhala.system.service.ZlHumanNumberStatisticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;

@Service
public class ZlHumanNumberStatisticImpl implements ZlHumanNumberStatisticService {

    @Autowired
    private ZlHumanNumberStatisticMapper zlHumanNumberStatisticMapper;

    @Override
    public int save(ZlHumanNumberStatistic zlHumanNumberStatistic) {
        return zlHumanNumberStatisticMapper.add(zlHumanNumberStatistic);
    }

    @Override
    public List<StatisticVO> statistic() {
        LocalDate currentDate = LocalDate.now();

        // 定义日期格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        // 格式化日期为字符串
        String formattedDate = currentDate.format(formatter);
        return zlHumanNumberStatisticMapper.statistic(formattedDate);
    }
    @Override
    public List<StatisticFindVO> record() {
        return zlHumanNumberStatisticMapper.record();
    }
}
